﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL;
using DAL;
using IDAL;
using Model;


namespace Flowers.Controllers
{
    public class OrderController : Controller
    {
        //
        // GET: /Order/
        BLL.Factory<IOrderDAL, OrderDAL> bll = new Factory<IOrderDAL, OrderDAL>();

        public ActionResult OrderIndex()
        {
            return View();
        }
        /// <summary>
        /// 显示所有销售订单
        /// </summary>
        /// <returns></returns>
        public ActionResult OrderIndexs()
        {
            return Json(bll.Fbll().OrderShow());
        }

        public ActionResult SelectAll()
        {
            string name = Request["OrderID"].ToString();
            return Json(bll.Fbll().SelectShow(name));
        }
        public ActionResult OrderSelectPay()
        {
            string name = Request["PayId"].ToString();
            return Json(bll.Fbll().SelectLike(name));
        }


        /// <summary>
        /// 根据状态来修改数据
        /// </summary>
        /// <returns></returns>
        public int OrderUpta()
        {
            string name = Request["OrderID"].ToString();
            if (bll.Fbll().OrderUpt(name) > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 根据状态来修改数据
        /// </summary>
        /// <returns></returns>
        public int OrderFull()
        {
            string name = Request["OrderID"].ToString();
            if (bll.Fbll().OrderFull(name) > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="name"></param>
        /// <param name="price"></param>
        /// <param name="ids"></param>
        /// <param name="numbers"></param>
        /// <param name="total"></param>
        /// <param name="address"></param>
        /// <param name="tell"></param>
        /// <param name="method"></param>
        /// <param name="paymethod"></param>
        /// <param name="zong"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public int AddOrders(string[] name, string[] price, string[] ids, string[] numbers, string[] total, string address, string tell, string method, string paymethod, int zong,string[] url)
        {
            var ii = bll.Fbll().AddOrder(name, price, ids, numbers, total, address, tell, method, paymethod, zong,url);
            
            return ii;
        }

    }
}
